#ifndef PROJECT_MANAGER_H
#define PROJECT_MANAGER_H

#include <QObject>
#include <QString>
#include <QFileSystemWatcher>
#include <QJsonObject>

class ProjectManager : public QObject {
    Q_OBJECT
    
public:
    explicit ProjectManager(QObject *parent = nullptr);
    
    bool createProject(const QString &path, const QString &name, const QString &templateName = "");
    bool openProject(const QString &path);
    bool saveProject();
    bool closeProject();
    
    QString projectName() const;
    QString projectPath() const;
    QStringList sourceFiles() const;
    
    void addFile(const QString &filePath);
    void removeFile(const QString &filePath);
    
    QJsonObject projectConfig() const;
    void setProjectConfig(const QJsonObject &config);
    
    bool isProjectOpen() const;
    
signals:
    void projectOpened(const QString &projectName);
    void projectClosed();
    void fileAdded(const QString &filePath);
    void fileRemoved(const QString &filePath);
    void fileChanged(const QString &filePath);
    
private:
    void loadProject();
    void setupFileWatcher();
    
    QString m_projectPath;
    QJsonObject m_projectConfig;
    QFileSystemWatcher m_fileWatcher;
};

#endif // PROJECT_MANAGER_H